﻿using Point24.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Point24.ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = new int[4];
            int index = 0;
            Console.InputEncoding = System.Text.Encoding.GetEncoding(936);
            Console.OutputEncoding = System.Text.Encoding.GetEncoding(936);
            while (index < 4)
            {
                Console.WriteLine($"请输入第{index + 1}个1-10的整数");

                char tempNumStr = System.Console.ReadKey().KeyChar;
                if (!Char.IsDigit(tempNumStr))
                {
                    Console.WriteLine("你输入的不是一个整数");
                    continue;
                }
                int tmpNum = int.Parse(tempNumStr.ToString());
                if (tmpNum < 0 || tmpNum > 10)
                {
                    Console.WriteLine("你输入的数字不是1-10的数字");
                    continue;
                }
                array[index++] = tmpNum;
            }
            Console.WriteLine($"你输入的4个1-10的整数为{string.Join(",", array)}");
            Console.WriteLine("结果如下：");
            var expressionList = Caculator.Point24(array);
            if (expressionList != null)
            {
                foreach (var expression in expressionList)
                {
                    System.Console.WriteLine($"方案：{expressionList.IndexOf(expression) + 1}{expression}");
                }
            }
            Console.WriteLine($"总共方案数量：{expressionList?.Count}");
            Console.WriteLine("按任意键退出！！！");
            Console.ReadKey();
        }
    }
}
